<template>
  <div class="t-dis">
    <div style="padding: 15px 23px 0 23px">
      <VolHeader
        icon="el-icon-warning-outline"
        text="查询条件"
        style="margin-bottom: 20px"
      >
      </VolHeader>
      <div class="vol-form-item" style="margin-bottom: 15px">
        <el-row :gutter="20">
        
          <el-col :span="6"
            ><div class="grid-content">
              <span style="float: left; line-height: 30px; font-size: 15px"
                >审核状态：</span
              >
              <el-select
                v-model="searchFields.shzt"
                placeholder="请选择审核状态"
                style="float: left; width: 80%"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select></div
          ></el-col>
          <el-col :span="6">
            <div class="block">
              <span style="float: left; line-height: 30px; font-size: 15px"
                >申请时间：</span
              >
              <el-date-picker
                style="float: left; width: 80%"
                v-model="searchFields.sq_sj"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </div>
          </el-col>
          <el-col :span="6"
            ><div class="grid-content">
              <div class="block">
                <span style="float: left; line-height: 30px; font-size: 15px"
                  >审核时间：</span
                >
                <el-date-picker
                  style="float: left; width: 80%"
                  v-model="searchFields.sh_sj"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                >
                </el-date-picker>
              </div></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content">
              <el-button
                type="primary"
                class="edit_btn"
                @click="btnSeach"
                style="font-size: 15px"
              >
                <i class="el-icon-search"></i>&nbsp;&nbsp;&nbsp;搜索</el-button
              >
            </div></el-col
          >
        </el-row>
      </div>
    </div>
    <div style="height: 10px; background: #eee"></div>
    <div class="example-tb">
      <div class="tb">
        <vol-table
          ref="table"
          :columns="columns"
          :max-height="580"
          :columnIndex="false"
          :index="false"
          :ck="false"
          :text-inline="false"
          :tableData="tableData"
          :paginationHide="false"
          @loadBefore="loadTableBefore"
          @loadAfter="loadTableAfter"
          url="/api/zm_data_record/GetData"
          :override="true"
         
        ></vol-table>
      </div>
      <br />
      <VolBox
        :lazy="true"
        v-model="model"
        :title="title"
        :detailParams="detailParams"
        :fistfileName="fistfileName"
        :ifShowPanel="ifShowPanel"
        :height="350"
        :width="width"
        :pdfwidth="pdfwidth"
      >
        <div>当前点击的行数据<br />{{ currentRow }}</div>
      </VolBox>

      <VolReonly
        :lazy="true"
        v-model="fmodel"
        :title="title"
        :detailParams="detailParams"
        :fistfileName="fistfileName"
         :ifShowPanel="ifShowPanel"
        :height="350"
        :width="width"
        :pdfwidth="pdfwidth"
      >
        <div>当前点击的行数据<br />{{ currentRow }}</div>
      </VolReonly>
    </div>
  </div>
</template>
<script>
import VolForm from "@/components/basic/VolForm.vue";
import VolHeader from "@/components/basic/VolHeader.vue";
//import table2 from "@/views/tables/applyauttable";

import VolTable from "@/components/basic/VolTable.vue";
//import pdfjsLib from 'pdfjs-dist';
//import * as pdfjsLib from 'pdfjs-dist';
import VolBox from "@/views/applyrectification.vue";
import VolReonly from "@/views/applyReonly.vue";
export default {
  components: {
    VolTable,
    VolBox,
    VolHeader,
    VolReonly,
  },
  methods: {
    btnSeach() {
      this.$refs.table.load();
    },
    loadTableBefore(param, callBack) {
      //生成查询条件
      param.wheres = [
        //设置为like模糊查询
        {
          name: "sq_sj",
          value: this.searchFields.sq_sj,
        },
        {
          name: "sh_sj",
          value: this.searchFields.sh_sj,
        },
        {
          name: "shzt",
          value: this.searchFields.shzt,
        },
      ];
      callBack(true); //此处必须进行回调，返回处理结果，如果是false，则不会执行后台查询
    },
    loadTableAfter(data, callBack) {
      //此处是从后台加数据后，你可以在渲染表格前，预先处理返回的数据
      callBack(true); //同上
    },
  },
  mounted() {
    // console.log('pdfjsLib',pdfjsLib)
    this.http.post("/api/user/getCurrentUserInfo", {}, true).then((x) => {
      if (!x.status) {
        return this.$message(x.message);
      }
      console.log('ce',x.data)
      if(x.data.workUnit===null ||  x.data.workUnit==="")
      {
        this.$alert("请先完善个人基本信息！", "消息提示", {
              confirmButtonText: "确定",
              type: "error",
              callback: (action) => {
                this.$router.push("/UserInfo");
              },
            });
      }
    })
    var param = {
      pageindex: this.pageindex,
      pagesize: this.pagesize,
    };
    this.http.post("/api/zm_data_record/GetData", param).then((result) => {
      this.tableData = result.rows;
    });
  },
  data() {
    return {
      loadKey: true,
      searchFields: {
        sq_sj: "",
        sh_sj: "",
        shzt: "",
      },
      options: [
        {
          value: -2,
          label: "全部",
        },
        {
          value: -1,
          label: "待审核",
        },
        {
          value: 0,
          label: "不通过",
        },
        {
          value: 1,
          label: "已通过",
        },
      ],
      currentRow: "",
      model: false,
      fmodel: false,
      emodel: false,
      width: "90%",
      pdfwidth: "50%",
      title: "测试",
      detailParams: "",
      fistfileName: "",
      url: "/api/app_news/upload", //使用后台自带的上传文件方法，也可以自定义方法上传
      text: "",
      tableData: [],
      projectList:{},
      ifShowPanel:null,
      columns: [
        //表配置
        {
          field: "data_id", //数据库表字段,必须和数据库一样，并且大小写一样
          type: "string", //数据类型
          isKey: true, //是否为主键字段
          width: 50, //表格宽度
          hidden: true, //是否显示
          readonly: true,
          require: true,
          align: "left", //文字显示位置left、center
        },
        {
          field: "idx",
          title: "序号",
          type: "string",
          width: 55,
          align: "center",
        },
        {
          field: "projectname",
          title: "项目名称",
          type: "string",
          width: 270,
          require: true,
          align: "left",
          cellStyle: (row, rowIndex, columnIndex) => {
            return { color: "#409EFF", cursor: "pointer" };
          },
          click: (row, column) => {
            this.title = row.projectname;
             if(row.xzqdm!==null && row.xzqdm!=="") //县级
            {
                this.ifShowPanel=false;
            }
            else
            {
               this.ifShowPanel=true;
            }
            this.http
              .post("/api/zm_data_record/AdminGetDetaileByID?id=" + row.data_id)
              .then((result) => {
                this.detailParams = result.Data;
                if (result.Data.thisdata != undefined) {
                  this.fistfileName = result.Data.thisdata.ssfa_name;
                }
              });
            this.fmodel = true;
          },
        },
        {
          field: "sqcs",
          title: "申请次数",
          type: "string",
          width: 55,
          align: "center",
        },
        {
          field: "shzt",
          title: "审核状态",
          type: "string",
          width: 60,
          align: "center",
          render: (h, { row, column, index }) => {
            if (row.shztname == "已通过") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--success el-tag--light"],
                    },
                    "已通过"
                  ),
                ]),
              ]);
            } else if (row.shztname == "未审核") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--warning el-tag--light"],
                    },
                    "待审核"
                  ),
                ]),
              ]);
            } else if (row.shztname == "不通过") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--danger el-tag--light"],
                    },
                    "不通过"
                  ),
                ]),
              ]);
            }
          },
        },
        {
          field: "jycs",
          title: "交验次数",
          type: "string",
          width: 55,
          align: "center",
        },
        {
          field: "xxtj_time",
          title: "线下提交时间",
          type: "datetime",
          width: 75,
          align: "center",
        },
        {
          field: "xxtj_state",
          title: "提交状态",
          type: "string",
          width: 55,
          align: "center",
          render: (h, { row, column, index }) => {
            if (row.xxtj_state == "已通过") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--success el-tag--light"],
                    },
                    "已通过"
                  ),
                ]),
              ]);
            }else if(row.xxtj_state=="正在提交中")
            {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--warning el-tag--light"],
                    },
                    "正在提交中"
                  ),
                ]),
              ]);
            }
          },
        },
        {
          field: "accept_state",
          title: "验收状态",
          type: "string",
          width: 70,
          align: "center",
          render: (h, { row, column, index }) => {
            if (row.accept_state == "已通过") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--success el-tag--light"],
                    },
                    "已通过"
                  ),
                ]),
              ]);
            }else if(row.accept_state=="正在验收中")
            {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--warning el-tag--light"],
                    },
                    "正在验收中"
                  ),
                ]),
              ]);
            }else if(row.accept_state=="不通过")
            {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--danger el-tag--light"],
                    },
                    "不通过"
                  ),
                ]),
              ]);
            }
          },
        },
        {
          field: "create_time",
          title: "申请时间",
          width: 115,
          type: "datetime",
          align: "center",
        },
        {
          field: "submit_state",
          title: "提交状态",
          width: 70,
          type: "string",
          align: "center",
          render: (h, { row, column, index }) => {
            if (row.submit_state == "已提交") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--success el-tag--light"],
                    },
                    "已提交"
                  ),
                ]),
              ]);
            } else if (row.submit_state == "未提交") {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-tag el-tag--info el-tag--light"],
                    },
                    "未提交"
                  ),
                ]),
              ]);
            }
          },
        },
        {
          field: "sh_name",
          title: "审核人",
          type: "string",
          width: 55,
          align: "center",
        },
        {
          field: "sh_time",
          title: "审核时间",
          type: "datetime",
          width: 110,
          align: "center",
        },
        {
          field: "citymc",
          title: "地市名称",
          type: "string",
          width: 60,
          align: "center",
        },
        {
          field: "xzqname",
          title: "区县名称",
          type: "string",
          width: 60,
          align: "center",
        },
        {
          title: "操作",
          type: "string",
          width: 60,
          align: "center",
          render: (h, { row, column, index }) => {
            if (row.submit_state == "未提交" && (row.role_id==="126" || row.role_id==="137")) {
              console.log('ccc',row)
              
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-icon-edit el-tag el-tag--light"],
                      style: { cursor: "pointer", "margin-right": "8px" },
                      onClick: (e) => {
                        this.$router.push("/applyedit?id="+row.data_id);
                        this.$store.state.data_id =row.data_id;
                        this.$store.state.projectname =row.projectname; 
                        this.fmodel = false;
                        this.model = false;
                      },
                    },
                    "编辑"
                  ),
                ]),
              ]);
            } else if (row.submit_state == "已提交"){
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-icon-check el-tag el-tag--light"],
                      style: { "margin-right": "8px", background: "#f0f0f0" },
                    },
                    "已提交"
                  ),
                ]),
              ]);
            }else  if (row.submit_state == "未提交")
            {
              return h("div", { style: {} }, [
                h("div", {}, [
                  h(
                    "span",
                    {
                      class: ["el-icon-close el-tag el-tag--light"],
                      style: { "margin-right": "8px", background: "#f0f0f0" },
                    },
                    "未提交"
                  ),
                ]),
              ]);
            }
          },
        },
      ],
    };
  },
};
</script>
<style lang="less" scoped>
.example-tb {
  padding: 15px;
}
.tb {
  margin-top: 15px;
}
.v-header {
  background: white;
  padding: 10px;
}
.t-dis {
  margin-bottom: 15px;
  background: white;
}
.t-dis ::v-deep(.example-tb .el-alert) {
  display: none;
}
.t-dis ::v-deep(.example-tb .tb) {
  margin-top: 0 !important;
}
.t-dis ::v-deep(.example-tb .search-info) {
  margin-left: -19px;
}
.el-row {
  margin-bottom: 10px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.edit_btn {
  min-height: 40px;
  min-width: 100px;
  background: #409eff 80%;
  border: #409eff;
  font-size: 20px;
}
</style>
